-
-
Notifications
You must be signed in to change notification settings - Fork 32k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimistic MQTT light #14401
Optimistic MQTT light #14401
Conversation
tests/components/light/test_mqtt.py
Outdated
'white_value': 50}) | ||
print(fake_state) | ||
with patch('homeassistant.components.light.mqtt.async_get_last_state', | ||
return_value=mock_coro(fake_state)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
tests/components/light/test_mqtt.py
Outdated
'color_temp': 100, | ||
'white_value': 50}) | ||
with patch('homeassistant.components.light.mqtt.async_get_last_state', | ||
return_value=mock_coro(fake_state)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continuation line under-indented for visual indent
'color_temp': 100, | ||
'white_value': 50}) | ||
|
||
with patch('homeassistant.components.light.mqtt_json.async_get_last_state', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
self.hass, self._topic[CONF_BRIGHTNESS_STATE_TOPIC], | ||
brightness_received, self._qos) | ||
self._brightness = 255 | ||
elif self._optimistic_brightness and last_state\ | ||
and last_state.attributes.get('brightness'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ATTR_BRIGHTNESS
from light/__init__.py
. And on other places where a const which is defined in light/__init__.py
make sense.
Description:
This is a follow-up to #14151
When the light works in optimistic mode, HA is unaware of the current light state and always defaults to OFF on restart.
This pull request restores the state (and attributes) of the light to the last state, which is somehow what is expected from an optimistic light (that it has kept the state since the last restart and not defaulted to OFF)
Related issue (if applicable): fixes #
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
REQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices: